﻿using UnityEngine;
using System.Collections;

public class TextHit : MonoBehaviour
{
    private float time = 3.0f;

    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (GetComponent<GUIText>().enabled)
        {
            time -= Time.deltaTime;
            if (time <= 0)
            {
                GetComponent<GUIText>().enabled = false;
                time = 3.0f;
            }
        }
    }

    void ShowHit(string message)
    {
        GetComponent<GUIText>().text = message;
        if (!GetComponent<GUIText>().enabled)
            GetComponent<GUIText>().enabled = true;
    }
}